﻿package Map
{
	public class Block extends Adjustable
	{
		protected var pos_x:uint;
		protected var pos_y:uint;
		public function Block()
		{
		}

		public virtual function initialize(x:uint,y:uint)
		{
			visible = false;
			setPosition(x,y);
		}

		public function setPosition(x:uint,y:uint)
		{
			this.pos_x = x;
			this.pos_y = y;
			this.x = pos_x * points_per_block;
			this.y = pos_y * points_per_block;
		}

		public function equals(x:uint,y:uint):Boolean
		{
			return ( (pos_x == x) && (pos_y == y) );
		}

		public virtual function destroy()
		{
			visible = false;
		}
		
		// update the position
		public override function update() {
			super.update();
			pos_x = x/points_per_block;
			pos_y = y/points_per_block;
		}
		
		public virtual function onMapReset() {
			visible = true;
		}
	}

}